package com.rankeiot.core.util.castor;




import com.rankeiot.core.util.JSONUtil;

import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("AlibabaConstantFieldShouldBeUpperCase")
public class MapCastor implements Castor<Map> {
    public static final MapCastor instance=new MapCastor();
    @Override
    public Map cast(Object v) {
        if(v==null){
            return new HashMap();
        }
        if(v instanceof Map){
            return (Map)v;
        }
        if(v instanceof CharSequence){
            return JSONUtil.parseObject(v.toString()); //JsonKit.parse(v.toString(),HashMap.class);//JSON.parseObject(v.toString());
        }
        return new HashMap();
    }
}
